package kosta.model.reply.news;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class NewsReplyDaoImpl implements NewsReplyDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	@Override
	public void insertReply(NewsReplyVO rvo) {
		System.out.println("re daoimpl"+rvo);
		sqlSessionTemplate.insert("newsreply.insertReply",rvo);
	}

	@Override
	public List<NewsReplyVO> getListReply(int bno) {
		System.out.println("getListReply Dao");
		return sqlSessionTemplate.selectList("newsreply.getListReply",bno);
	}

	@Override
	public void deleteReply(int rno) {
		sqlSessionTemplate.delete("newsreply.replyDelete",rno);
		
	}

	@Override
	public void updateReply(NewsReplyVO rvo) {
		sqlSessionTemplate.update("newsreply.replyUpdate",rvo);
		
	}

	@Override
	public void updateRestep(int ref, int restep) throws SQLException {
		HashMap<String,Integer> map=new HashMap<String,Integer>();
		map.put("ref", ref);
		map.put("restep", restep);
		sqlSessionTemplate.insert("newsreply.updateReReply",map);
		
	}

	@Override
	public void insertReReply(NewsReplyVO rvo) throws SQLException {
		sqlSessionTemplate.insert("newsreply.insertReReply",rvo	);
		
	}

	@Override
	public int selectRestep(int ref) throws SQLException {
		return sqlSessionTemplate.selectOne("newsreply.selectRestep",ref);
	}
	
}
